<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="__PUBLIC__/Center/css/ch-ui.admin.css">
	<link rel="stylesheet" href="__PUBLIC__/Center/font/css/font-awesome.min.css">
	<script src="__PUBLIC__/Center/js/jquery.js"></script>
	<script src="__PUBLIC__/Center/js/jquery-1.12.4.js"></script>
	<script src="__PUBLIC__/Center/js/jquery-ui.js"></script>
	<!--引入自定义js文件-->
	<script src="__PUBLIC__/Center/js/setconfig.js"></script>
	<script src="__PUBLIC__/Center/js/layer.js"></script>
	<!--引入自定义css样式文件-->
	<link rel="stylesheet" href="__PUBLIC__/Center/css/setconfig.css" />
    <script type="text/javascript">
    	//常量定义区域
    	const MODULE = "__MODULE__";
    	//1.检测是否存在主配置文件
    	<?php
    		if($has_main_conf):
    	?>
    		var has_main_conf = true;
    	<?php
    		else:
    	?>
    		var has_main_conf = false;
    	<?php
    		endif;
    	?>
    </script>
    <script>
    	$(function(){
    		$('#main_conf_submit').bind('click',function(){
    			layer.confirm('确定要提交保存吗?', {
					btn: ['是的','取消']
				}, function(){
					$('form').trigger('submit');
				}, function(){
				 	layer.close();
				});
    		});
    		//全选操作
    		$('#select_all').bind('click',function(){
    			$('.sub_list_span').each(function(){
    				this.checked = true;
				//联动span背景颜色
			    	if(this.checked){
			    		$(this).parent().css({
			    			'background':'gray',
							'color':'white',
			    		});
			    	}else{
			    		$(this).parent().css({
			    			'background':'white',
							'color':'black',
			    		});
			    	}			
			});
    		});
    		//反选操作
    		$('#select_back').bind('click',function(){
    			//初始化样式
    			$('.sub_list_span').each(function(){
    				if(this.checked){
    					this.checked = false;
    				}else{
    					this.checked = true;
    				}
				//联动span背景颜色
			    	if(this.checked){
			    		$(this).parent().css({
			    			'background':'gray',
							'color':'white',
			    		});
			    	}else{
			    		$(this).parent().css({
			    			'background':'white',
							'color':'black',
			    		});
			    	}			
			});
    		});
    	});
    </script>
</head>
<body>
	<div class="crumb_warp">
		<!-- 功能按钮区域开始 -->
		<i class="fa fa-home"></i>&nbsp;子集综合配置面板
		<input id="main_conf_submit" style="background:red;border:0;" value="保存当前配置"  type="button">
		<input name="search_name" value="刷新数据" type="button" onclick="location.reload()">
		<input type="button" class="back"  id="select_all"  value="全选">
		<input type="button" class="back"  id="select_back"  value="反选">
		<!-- 功能按钮区域结束 -->
	</div>
 	<div id="info">
    	<form action="__CONTROLLER__/createMainConfig" method="post">
    		<!-- 追加子集name -->
    		<input type="hidden" name="item_name" value="<?php echo $name;?>"/>
    		<div>
    			<h2 name="<?php echo $name;?>">
    				<?php echo $info_list['caption']?>
        		</h2>
    		</div>
        	<div class="info">
    			<div style="overflow: auto;" class="sub_span_list">
        			<!--遍历二级子集开始-->
        			<?php
        				foreach($info_list['sublist'] as $k => $v):	
        			?>
            			<span directory="<?php echo $v['dictionaries'];?>"  class="second_span" name="<?php echo $k;?>">
            				<!--检测是否有字典-->
            				<span style="cursor:pointer" title="<?php echo $v['caption'];?>"><?php echo mb_substr($v['caption'],0,6,'utf-8');?></span>
            				<input dictionaries="<?php echo $v['dictionaries'];?>"
            				<?php
            					if($v['display']){
        						echo "checked=true";
        					}
            				?> 
            				type="checkbox" class="sub_list_span" value="<?php echo $k;?>" name="subitem[]" />
            			</span>
        			<?php
        				endforeach;
        			?>
        			<!--遍历二级子集结束-->
        		</div>
        	</div>
        </form>
    </div>
</body>
</html>